package com.example.demo.sort;

public class Get {
    public static void main(String[] args) {

    }

    public  static int binarySearch(int[] arr,int data){
        int low = 0;
        int high = arr.length-1;
        while (low <= high){
            int middle = (low + high) / 2;
            if(arr[middle] < data){
                low = middle+1;
            }else if(arr[middle] > data){
                high = middle-1;
            }else if(arr[middle] == data){
                return middle;
            }
        }
        return -1;
    }
}
